export function formatMessageTime(date) {
	const now = new Date();

	if (isSameDay(date, now)) {
		return formatTime(date);
	} else if (isThisWeek(date, now)) {
		return formatWeekday(date);
	} else {
		return formatDate(date);
	}
}

function isSameDay(d1, d2) {
	return d1.getFullYear() === d2.getFullYear() &&
		d1.getMonth() === d2.getMonth() &&
		d1.getDate() === d2.getDate();
}

function isThisWeek(d1, d2) {
	// 判断一周内
}

function formatTime(date) {
	return date.getHours() + ':' + date.getMinutes();
}

function formatWeekday(date) {
	return date.toLocaleDateString('default', {
		weekday: 'long'
	});
}

function formatDate(date) {
	return date.getFullYear() + '/' + (date.getMonth() + 1) + '/' + date.getDate();
}